package com.example.peanutsubway.web;

import com.alibaba.fastjson.JSONObject;
import com.example.peanutsubway.entity.RoleInfo;
import com.example.peanutsubway.service.RoleInfoService;
import com.example.peanutsubway.service.impl.RoleInfoServiceImpl;
import com.example.peanutsubway.util.PageInfo;

import javax.servlet.annotation.WebServlet;

/**
 * @Author：zzt
 * @Version：1.0
 * @Date：2021/10/18-14:57
 * @Since:jdk1.8
 * @Description:
 */
@WebServlet("/role.do")
public class RoleServlet extends BaseServlet<RoleInfo> {
    private RoleInfoService roleInfoService = new RoleInfoServiceImpl();
    public String showAllRole(RoleInfo roleInfo){
        String nowPage = request.getParameter("page");
        String pageNum = request.getParameter("pageSize");
        PageInfo allRole = roleInfoService.findAllRole(roleInfo, nowPage, pageNum);
        return JSONObject.toJSONString(allRole);
    }

    public String deleteRole(){
        String rid = request.getParameter("rid");
        return roleInfoService.deleteRole(Integer.parseInt(rid)).toString();
    }

    public String updateRole(RoleInfo roleInfo){
       return roleInfoService.updateRole(roleInfo).toString();
    }
}
